@model List<DotnetSpider.DownloadAgentRegisterCenter.Entity.DownloaderAgent>

@section breadcrumb{
    <li >
        <a href="#">Agent</a>
    </li>
}

@section header{
    Agent<small v-text="moduleDescription"></small>
}

<div class="col-xs-12">
    <div class="box">
        <div class="box-header">
            <div class="box-title">
                &ensp;
            </div>
            <div class="box-tools">
                &ensp;
            </div>
        </div>
        <!-- /.box-header -->
        <div class="box-body table-responsive no-padding">
            <table class="table table-bordered">
                <tbody>
                <tr>
                    <th>#</th>
                    <th>Name</th>
                    <th>CPU Count</th>
                    <th>Total Mem</th>
                    <th>CreationTime</th>
                    <th>Heartbeat</th>
                    <th>Action</th>
                </tr>
                @if (Model == null || !Model.Any())
                {
                    <tr>
                        <td colspan="7">
                            None
                        </td>
                    </tr>
                }
                else
                {
                    foreach (var item in Model)
                    {
                        <tr >
                            <td style="width: 15px;">
                                @if (item.IsActive())
                                {
                                    <span style="background-color: green">&ensp;&ensp;&ensp;&ensp;</span>
                                }
                                else
                                {
                                    <span style="background-color: red">&ensp;&ensp;&ensp;&ensp;</span>
                                }
                            </td>
                            <td>
                                <span>@item.Name</span>
                            </td>
                            <td>
                                <span>@item.ProcessorCount</span>
                            </td>
                            <td>
                                <span>@item.TotalMemory</span>
                            </td>
                            <td>
                                <span>@item.CreationTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")</span>
                            </td>
                            <td>
                                <span>@item.LastModificationTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")</span>
                            </td>
                            <td>
                                 <button class="btn btn-default btn-sm  btn-flat" onclick="deleteAgent('@item.Id')">Delete</button>
                                <a class="btn btn-default btn-sm btn-flat" href="/downloader-agent/@item.Id/heartbeat">Heartbeat</a>
                                <button @(item.IsActive() ? "" : "disabled") class="btn btn-default btn-sm  btn-flat" onclick="exit('@item.Id')">Exit</button>
                            </td>
                        </tr>
                    }
                }

                </tbody>
            </table>
        </div>
        <!-- /.box-body -->
    </div>
    <!-- /.box -->
</div>

@section scripts{
    <environment names="Development">
        <script src="~/js/agent.js" asp-append-version="true"></script>
    </environment>
    <environment names="Staging,Production">
        <script src="~/js/agent.min.js" asp-append-version="true"></script>
    </environment>
}